CONTENTS | INDEX | PREV | NEXT
 strcpy

   NAME
    strcpy  - copy a string returning a pointer to the beginning of the
          destination.

   SYNOPSIS
    char *ptr = strcpy(d, s);
    char *d;
    char *s;

   FUNCTION
    Copy the nul terminated string pointed to by s to the buffer d.
    The nul is copied.  The first argument is returned (a pointer to
    the buffer d).

   EXAMPLE
    #include <stdio.h>
    #include <string.h>
    #include <assert.h>

    /*
     *  note that the stpcpy() example accomplishes the same thing and
     *  is more efficient, but also requires the use of a temporary
     *  pointer as well as cluttering the source and being non-standard.
     *
     *  strcpy()/strcat() is more portable though less efficient.
     */

    main()
    {
        char *buf1 = "hello";
        char *buf2 = "123";
        char dest[32];
        char *ptr;

        strcpy(dest, buf1);
        strcat(dest, buf2);
        puts(dest);                     /* hello123 */
        return(0);
    }

   INPUTS
    char *d;    pointer to beginning of destination buffer
    char *s;    pointer to beginning of source string

   RESULTS
    char *ptr;  same as the destination buffer pointer (d).

   SEE ALSO
    stpcpy